package com.patterns.design.security.web.struts.sample3.action;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.owasp.esapi.Encoder;

import com.patterns.design.security.web.struts.common.BaseAction;
import com.patterns.design.security.web.struts.sample3.form.SampleForm;

public class InputAction extends BaseAction{

	@Override
	public ActionForward executeAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		SampleForm sampleForm=(SampleForm)form;
		sampleForm.setMySampleInt(4);
		sampleForm.setMySampleDate("01/01/2012");
		sampleForm.setMySampleFlag(true);
		sampleForm.setMyPersonalEmail("alain.cieslik@securitydesignpatterns.com");
		sampleForm.setMySampleString("test");
		sampleForm.setMyDynamicFragmentHtml("<b>hello</b>");
		
		return mapping.getInputForward();
	}

	@Override
	public void encodeData(Encoder encoder) throws Exception {
		
	}

	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){
		ActionErrors errors=new ActionErrors();
		
		return errors;
	}
}
